﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MVCFoto.Model;
using MVCFoto.BLL;
namespace MVCFoto.Web.Views.Shared
{
    public partial class UserTopAlbums<T> : System.Web.Mvc.ViewUserControl<UserInfo>
    {
        protected string GetUserName(UserInfo ui)
        {
            if (ui.UserID == BLL.User.MyID)
                return "我";
            else
                return ui.UserName;
        }
        protected IList<AlbumInfo> GetUserAlbums(int userId)
        {          
           
            BLL.Photo p = new MVCFoto.BLL.Photo();
            Photo.AlbumPrivacy privacy = Photo.AlbumPrivacy.Public;
            //根据privacy控制隐私项的显示 
            if (userId == BLL.User.MyID)
            {//self
                privacy = Photo.AlbumPrivacy.Private;               
            }
            else if (BLL.Friend.IsUserFriend(userId))
            {
                privacy = Photo.AlbumPrivacy.Friend;               
            }
            int itemcount = 0;
            return p.GetUserAlbums(userId,privacy,1,5,out itemcount);
        }
    }
}
